package com.example.automatic;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.blankj.utilcode.util.DeviceUtils;
import com.blankj.utilcode.util.PhoneUtils;
import java.util.Arrays;

public class MainActivity extends AppCompatActivity {

    private Button btnGetInfo;
    private TextView textInfo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        if (!Settings.canDrawOverlays(this)) {
            startActivityForResult(new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName())), 0);
        }

        btnGetInfo = findViewById(R.id.btn_get_info);
        textInfo = findViewById(R.id.text_info);
        btnGetInfo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                StringBuilder sb = new StringBuilder();
                //获取设备号
                sb.append("设备号getDeviceId：").append(PhoneUtils.getDeviceId()).append("\n");
                //获取序列号
                sb.append("序列号getSerial：").append(PhoneUtils.getSerial()).append("\n");
                //获取 IMEI 码
                sb.append("IMEI码getIMEI：").append(PhoneUtils.getIMEI()).append("\n");
                //获取 MEID 码
                sb.append("MEID码getMEID：").append(PhoneUtils.getMEID()).append("\n");
                //获取 IMSI 码
                sb.append("IMSI码getIMSI：").append(PhoneUtils.getIMSI()).append("\n");
                //获取设备系统版本号
                sb.append("设备系统版本号getSDKVersionName：").append(DeviceUtils.getSDKVersionName()).append("\n");
                //获取设备系统版本码
                sb.append("设备系统版本码getSDKVersionCode：").append(DeviceUtils.getSDKVersionCode()).append("\n");
                //获取设备 AndroidID
                sb.append("AndroidID getAndroidID：").append(DeviceUtils.getAndroidID()).append("\n");
                //获取设备 MAC 地址
                sb.append("设备MAC地址getMacAddress：").append(DeviceUtils.getMacAddress()).append("\n");
                //获取设备厂商
                sb.append("设备厂商getManufacturer：").append(DeviceUtils.getManufacturer()).append("\n");
                //获取设备型号
                sb.append("设备型号getModel：").append(DeviceUtils.getModel()).append("\n");
                //获取设备 ABIs
                sb.append("设备ABIs getABIs：").append(Arrays.toString(DeviceUtils.getABIs())).append("\n");
                textInfo.setText(sb.toString());
            }
        });

    }


}
